Trigger: Combination
The combination trigger is a very powerful feature which allows the logical combination of up to 4 other triggers. The combination trigger activates when the input triggers are active according to a user-defined logic table. Any possible logical expression with up to 4 inputs can be provided.
Combination triggers are updated every event cycle.
Configuration
There are two configuration parameters: an unsigned 16-bit logic value and a list of 4 input triggers.
Input Triggers
The input triggers are specified by the trigger instance ID. Any valid trigger ID other than the one being configured can be specified, including other combination triggers. In this documentation and in software, these 4 inputs are referred to as inputs A through D, with A being first in the list. Unused inputs can be set to trigger ID 0 which means always inactive.
Note: It’s possible to specify the trigger’s own ID as an input, in which case the value will be the trigger’s previous state. Generally this should be avoided as care must be taken to avoid it getting stuck in one state or rapidly toggling between active and inactive.
Logical Truth Table
A logic table lists every possible combination of input states in a specific order, along with the desired output state. For the combination trigger, it looks like the table below. The input triggers are labeled A through D, with A representing the first trigger in the list. ‘0' represents an inactive input while '1’ represents an active input. Each row is one possible situation given 4 input triggers.
D | C | B | A | Output | Comment |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | No inputs active | |
0 | 0 | 0 | 1 | Only A is active | |
0 | 0 | 1 | 0 | Only B is active | |
0 | 0 | 1 | 1 | Both A and B are active | |
0 | 1 | 0 | 0 | Only C is active | |
0 | 1 | 0 | 1 | Both A and C | |
0 | 1 | 1 | 0 | Both B and C | |
0 | 1 | 1 | 1 | A, B, and C | |
1 | 0 | 0 | 0 | Only D | |
1 | 0 | 0 | 1 | A and D | |
1 | 0 | 1 | 0 | B and D | |
1 | 0 | 1 | 1 | A, B, and D | |
1 | 1 | 0 | 0 | C and D | |
1 | 1 | 0 | 1 | A, C, and D | |
1 | 1 | 1 | 0 | B, C, and D | |
1 | 1 | 1 | 1 | All 4 active |
To complete the table, write a ‘1
' in the output column for any row which should activate the combination trigger. Write ‘0
’ in the other rows. Here’s an example for the expression “C and (A or B)
”.
A | B | C | D | Output | Comment |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | C is inactive, therefore all these rows are 0. |
0 | 0 | 0 | 1 | 0 | |
0 | 0 | 1 | 0 | 0 | |
0 | 0 | 1 | 1 | 0 | |
0 | 1 | 0 | 0 | 0 | C is active, but not A or B. |
0 | 1 | 0 | 1 | 1 | Expression is satisfied. |
0 | 1 | 1 | 0 | 1 | |
0 | 1 | 1 | 1 | 1 | |
1 | 0 | 0 | 0 | 0 | The only difference between these 8 rows and the previous 8 is that input D would be active. The previous 8 rows are copied so the result is the same regardless of input D. Technically, as long as trigger id 0 is used for input D, it can never be active and any value can be written in these rows without affecting the result. |
1 | 0 | 0 | 1 | 0 | |
1 | 0 | 1 | 0 | 0 | |
1 | 0 | 1 | 1 | 0 | |
1 | 1 | 0 | 0 | 0 | |
1 | 1 | 0 | 1 | 1 | |
1 | 1 | 1 | 0 | 1 | |
1 | 1 | 1 | 1 | 1 |
To convert this table to the 16-bit integer required in the MIP command, take the output column and rotate it 90 degrees to the right; the top bit in the first row is the least significant bit and the bottom bit is the most significant. The value for the above example is 1110000011100000 in binary, or E0E0 in hexadecimal. This is the value that would be used to configure the combination trigger.
Unused inputs
The trigger assumes there are 4 inputs, but many times only 2 or 3 are needed. The unused trigger inputs should be set to trigger 0, which is not a valid trigger instance (trigger instance IDs start with 1). For simplicity, use inputs in order and leave the unused ones at the end. Though it’s not required, this makes building the logic table easier.
The logic table has repeating patterns. Each additional input doubles the length of the table. Thus, every unused input halves the length of the table. For two inputs, the table needs to be only 4 rows. To be independent of the unused inputs, technically the bit pattern should be repeated until all 16 bits are filled. As noted in the comment above however, since the unused inputs with trigger ID 0 are always inactive, unused rows can be any value. It’s generally safe to just pad the remaining bits with 0. For the example above, that would result in the value 0x00E0 instead of 0xE0E0.
It’s possible to select the same trigger twice in two different inputs, though there is generally no advantage to doing so outside of testing.
Common Logic Values
Most use cases require only basic logic such as ALL or NONE. A few logic values have been defined below for convenience.
Value | Name | Notes |
---|---|---|
0x0000 | Never | Never activates. Only useful for testing. |
0x0001 | None / Nor | Only active if no inputs are active. |
0x0002 | A only | Activates if A is the only active input. |
0x0004 | B only | Activates if B is the only active input. |
0x0008 | A and B only | Activates if A and B but not C and D are active. Same as 0x8888 if C and D are unused. |
0x8888 | A and B | C, D are irrelevant. |
0x8080 | A, B, and C | D is irrelevant. |
0x8000 | All | All 4 inputs must be active (requires all 4 inputs to be used) |
0x6666 | A xor B | A or B but not both; C and D irrelevant. |
0xFFFE | Any / Or | Any input or multiple inputs; opposite of None (0x0001). Can be used with fewer than 4 inputs if unused trigger IDs are 0. |
0xFFFF | Always | Always active. Only useful for testing. |
Memory and Latching Behavior (Advanced)
As mentioned in the note above, it’s possible to specify the trigger’s own ID as an input. The input state in this case is the result from the previous event cycle. It’s also possible to link combination triggers in a circular fashion. This feedback mechanism can be used to implement a set/reset latch for things like threshold hysteresis.
A set/reset latch needs 3 inputs: set, reset, and the previous state. The latch is active if:
- The set input is active (A), or
- The output was previously active (C) and the reset input is inactive (not B).
As an example, assume the combination trigger is instance 4, the set input will come from trigger 1, and the reset input from trigger 2. The input IDs would then be (1,2,4,0), and the logic expression would be (A or (C and not B). By filling out the first half of the table (because D is unused), the binary value 00100000 (20 in hexadecimal) is obtained. Padding with 0 for the second half gives the hexadecimal value 0020.
The final configuration would be logic value 0x0020 and triggers (1,2,4,0).
Examples
Using Two Thresholds with a Combination Trigger
Using a Latching Combination Trigger for Hysteresis